'''
Created on 2009-12-9

@author: Jialai_Zhu
'''
import re
import string
def http1(url):
    res=(
     re.compile('(https?://)(.*?)$'),
     re.compile('(https?://)(.*?)\0'),
     re.compile('(https?://)(.*?)[\s\t]')
     )
    for p in res:
        ret = p.findall(url)
        if len(ret):
            link = ret[0][0]+ret[0][1]
            pos = string.find(link,['\t','\s','\0'])
            if pos>0:
                return link[0:pos]
            return link    
    return None

def normalize_url(data):
    i = len(data) - 1
    while 1:
        if data[i] == '/':
            data = data[0:i]
            i -= 1
        else:
            return data  
